<?php
/* @var $this GismarkerController */
/* @var $model Gismarker */
/* @var $form CActiveForm */
?>



  
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA3xYyrj4ARm7I8UnoqfJM2H0qR5hdigac&sensor=true"></script>
    <script>
		var map;

		function initialize() {
		  var mapOptions = {
		    disableDefaultUI: 0,
		    disableDoubleClickZoom: 0,
		    draggable: 1,
		    scrollwheel: 1,
		    zoom: 12,
		    center: new google.maps.LatLng(-6.190817,106.798199),
		    mapTypeId: google.maps.MapTypeId.ROADMAP
		  };
		  map = new google.maps.Map(document.getElementById('map-canvas'),
		      mapOptions);

		  google.maps.event.addDomListener(map, 'click', function(){
		      var str = map.getCenter().toString();
		      
		     document.getElementById("txt_latitude").value = str.split('(')[1].split(',')[0];
		     document.getElementById("txt_longitude").value = str.split(',')[1].split(')')[0];
		  }
		);
		}

		google.maps.event.addDomListener(window, 'load', initialize);
    </script>
	<style>
	.google-maps {
		position: relative;
		padding-bottom: 40%; // This is the aspect ratio
		height: 0;
		overflow: hidden;
	}
	.google-maps iframe {
		position: absolute;
		top: 0;
		left: 0;
		/*width: 100% !important;*/
		/*height: 60% !important;*/
	}
</style>




	<p class="note">Fields with <span class="required">*</span> are required.</p>
	<br>
	<?php //echo $form->errorSummary($model); ?>
	
	<?php
		$form = $this->beginWidget('bootstrap.widgets.BsActiveForm', array(
		    'layout' => BsHtml::FORM_LAYOUT_HORIZONTAL,
		    'enableAjaxValidation' => false,
		    'id' => 'gismarker-form',
		    'htmlOptions' => array(
		        'class' => 'bs-example'
		    )
		));
	?>
	<fieldset>
		<?php
			echo $form->textFieldControlGroup($model, 'MarkerID', array('value'=>'Generate By System', 'ReadOnly'=>true, 'disabled'=>true));
		?>
		<br><br>
		
		<?php
			$listMap = Gismapoption::model()->findAll('isActive = 1');
            $listData = array();
                
            for ($i = 0; $i < count($listMap); $i ++){
                $listData['Map Option'] = array($listMap[$i]->MapID => $listMap[$i]->MapTitle);
            }

			echo $form->dropDownListControlGroup($model, 'MapID', $listData);
		?>
		<?php
			echo $form->textFieldControlGroup($model, 'Name',array('size'=>60,'maxlength'=>100));
		?>


		<div class="google-maps" id="map-canvas" class="col-md-2">
			<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m12!1m3!1d16326126.934178308!2d118.0148634!3d-2.5489260000000002!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2sus!4v1400474332464" width="600" height="450" frameborder="0" style="border:0;"></iframe>
		</div>		
		<br>
		<?php
			echo $form->textFieldControlGroup($model, 'Latitude',array('id'=>'txt_latitude', 'disabled'=>true));
		?>
		<?php
			echo $form->textFieldControlGroup($model, 'Longitude',array('id'=>'txt_longitude', 'disabled'=>true));
		?>
		<?php
			echo $form->fileFieldControlGroup($model, 'MarkerImageURL', array(
			    'placeholder' => 'fileField'
			));
		?>
		<?php
			echo $form->textFieldControlGroup($model, 'MarkerSizeX', array('style'=>'width:30%;'));
		?>
		<?php
			echo $form->textFieldControlGroup($model, 'MarkerSizeY', array('style'=>'width:30%;'));
		?>
		<?php
			echo $form->textFieldControlGroup($model, 'MarkerOriginX', array('style'=>'width:30%;'));
		?>
		<?php
			echo $form->textFieldControlGroup($model, 'MarkerOriginY', array('style'=>'width:30%;'));
		?>
		<?php
			echo $form->textFieldControlGroup($model, 'MarkerAnchorX', array('style'=>'width:30%;'));
		?>
		<?php
			echo $form->textFieldControlGroup($model, 'MarkerAnchorY', array('style'=>'width:30%;'));
		?>
		<?php
			echo $form->textFieldControlGroup($model, 'Title',array('size'=>50,'maxlength'=>50));
		?>
		<?php
			echo $form->textAreaControlGroup($model, 'Message',array('rows'=>6, 'cols'=>50));
		?>
		<?php
			echo $form->checkBoxControlGroup($model, 'isActive',array('checked'=>Yii::app()->getController()->getAction()->id=='create'?TRUE:$model->isActive));
		?>
	</fieldset>
	</br>
	<?php
		echo BsHtml::formActions(array(
		    BsHtml::submitButton('Submit', array(
		        'color' => BsHtml::BUTTON_COLOR_PRIMARY
		    ))
		));
	?>

<?php $this->endWidget(); ?>

</div><!-- form -->